package com.hirain.fbg.sys.controller;

import com.hirain.fbg.sys.service.LoginService;
import com.hirain.fbg.util.IPUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by caicf on 2016/7/11.
 */
@Controller
@RequestMapping("/sys")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @RequestMapping(value = "/login",method = {RequestMethod.POST,RequestMethod.GET})
    public String login(HttpServletRequest request){
//        String username=request.getParameter("username");
//        String password=request.getParameter("password");
//        System.out.println(username+password);
//        if (!username.equals("")&&!(username==null)){
//            User userDB=loginService.getUser(username);
//            if (username.equals(userDB.getUsername())&& MD5.check(password,userDB.getPassword())){
//                return "home";
//            }
//        }
        String ip= IPUtil.getIpAddr(request);
        System.out.println("IP地址: "+ ip);
        System.out.println(request.getRemoteAddr());
        System.out.println("sys login");
        return "sys/index";
    }


    @RequestMapping(value = "/baidumap")
    public String baidumap(HttpServletRequest request) {
        System.out.println("sys/baidumap");
        return "sys/baidumap";
    }

}
